/* 
 * Copyright 2014 ShangDao.Ltd  All rights reserved.
 * SiChuan ShangDao.Ltd PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * 
 * @ActSetting.java  2014-9-12 上午11:28:02 - Carson
 * @author Guzhu
 * @email:muyi126@163.com
 * @version 1.0
 */

package com.android.tiango.baba.act;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.TextView;

import com.android.scsd.tiango.R;
import com.android.tiango.baba.BaBaseActivity;
import com.android.tiango.baba.cookie.ShareCookie;
import com.android.tiango.baba.util.Constants;
import com.android.tiango.baba.util.ToastUtils;
import com.android.tiango.baba.view.AppTitleBar;
import com.tencent.connect.auth.QQAuth;

/**
 * 设置页面
 * @author YW_pc
 * 
 */
public class ActSetting extends BaBaseActivity implements OnClickListener {

	private TextView tv_flowsetting;
	private TextView tv_picdown;
	private TextView tv_clear;
	private TextView tv_checkUpdate;
	private TextView tv_about;
	private CheckBox cb_down;
	private View vLogout;
	private TextView tv_logout;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.layout_setting);
		findViewById();
	}

	private void findViewById() {
		mTitleBar = (AppTitleBar) findViewById(R.id.titlebar);
		mTitleBar.setTitle("设置");
		setBackOnClickListener();

		tv_flowsetting = (TextView) findViewById(R.id.tv_flowsetting);
		tv_picdown = (TextView) findViewById(R.id.tv_picdown);
		tv_checkUpdate = (TextView) findViewById(R.id.tv_check_update);
		tv_about = (TextView) findViewById(R.id.tv_about);
		vLogout = findViewById(R.id.layout_logout);
		tv_logout = (TextView) findViewById(R.id.tv_logout);
		tv_clear = (TextView) findViewById(R.id.tv_clear);
		tv_clear.setOnClickListener(this);
		tv_checkUpdate.setOnClickListener(this);
		tv_about.setOnClickListener(this);
		tv_logout.setOnClickListener(this);
		cb_down = (CheckBox) findViewById(R.id.cb_down);
		tv_about.setText("关于");// + StringUtil.getVerName(this)
	}

	// @Override
	// protected void onResume() {
	// refreshViews();
	// super.onResume();
	// }

	// private void refreshViews() {
	// mAccessToken = AccessTokenKeeper.readAccessToken(this);
	// if (mAccessToken == null || !mAccessToken.isSessionValid()) {
	// tv_sina.setTextColor(Color.GRAY);
	// tv_sina.setText("未绑定");
	// ll_sina.setOnClickListener(new OnClickListener() {
	//
	// @Override
	// public void onClick(View v) {
	// if (null == mSsoHandler && mAuthInfo != null) {
	// WeiboAuth weiboAuth = new WeiboAuth(ActSetting.this, mAuthInfo);
	// mSsoHandler = new SsoHandler(ActSetting.this, weiboAuth);
	// }
	// if (mSsoHandler != null) {
	// mSsoHandler.authorize(sinaLoginListener);
	// }
	// }
	// });
	// } else {
	// tv_sina.setTextColor(Color.RED);
	// tv_sina.setText("已绑定");
	// ll_sina.setOnClickListener(new OnClickListener() {
	//
	// @Override
	// public void onClick(View v) {
	// showDialogMessage("是否取消绑定", new DialogInterface.OnClickListener() {
	// @Override
	// public void onClick(DialogInterface dialog, int which) {
	// AccessTokenKeeper.clear(ActSetting.this);
	// refreshViews();
	// dialog.dismiss();
	// }
	// }, new DialogInterface.OnClickListener() {
	// @Override
	// public void onClick(DialogInterface dialog, int which) {
	// }
	// });
	// }
	// });
	// }
	//
	// if (ShareCookie.isLoginAuth()) {
	// // vLogout.set;
	// tv_logout.setText("退出当前状态");
	// } else {
	// tv_logout.setText("登录");
	// }
	// }

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tv_flowsetting:

			break;
		case R.id.tv_picdown:

			break;

		case R.id.tv_sina:// 分享

			break;
		case R.id.tv_clear:// 清除緩存
			ToastUtils.showMessage("清除缓存成功！");
			break;
		case R.id.tv_check_update:
			// CommUtil.getVersion(this, true);
			break;
		case R.id.tv_about:
			Intent intent = new Intent(this, ActAbout.class);
			intent.putExtra(Constants.NAME, "关于");
			intent.putExtra(Constants.DATA, "file:///android_asset/about.html");
			startActivity(intent);
			break;
		case R.id.tv_logout:
			if (ShareCookie.isLoginAuth()) {
//				logout();
			} else {
//				showActivity(ActLogin.class, true);
			}
			break;

		default:
			break;
		}
	}
 
	// public void logout() {
	// showDialogMessage("确认退出登录？", new DialogInterface.OnClickListener() {
	// @Override
	// public void onClick(DialogInterface dialog, int which) {
	// ShareCookie.clearUserInfo();
	// QQAuth mQQAuth = QQAuth.createInstance(Constant.APP_ID, getApplicationContext());
	// mQQAuth.logout(ActSetting.this);
	// ActHome_Three.refashIndex(FraInformation.class.getSimpleName());
	// AccessTokenKeeper.clear(ActSetting.this);
	// ToastUtil.showMessage("注销成功！");
	// dialog.dismiss();
	//
	// onBackPressed();
	// }
	// }, new DialogInterface.OnClickListener() {
	// @Override
	// public void onClick(DialogInterface dialog, int which) {
	//
	// }
	// });
	// }

}
